"""定义分页模型类的文件."""
from fastapi import Query
from pydantic import BaseModel, Field


class PagenationRequest(BaseModel):
# “页面请求模型”
    page: int = Field(
        Query(default=1,
              ge=1,
              title="页码",
              description="要提取的结果的页码")
    )
    per_page: int = Field(
        Query(default=10,
              ge=1,
              le=100,
              title="输出的数量",
              description="每页的结果数(最大值 100)")
    )

    @property
    def offset(self) -> int:
        """根据页码 offset要计算."""
        return (self.page - 1) * self.per_page


class PaginationResponse(BaseModel):
    """寻呼信息响应模型"""
    total_records: int
    total_pages: int
